<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
	<th:block th:include="include :: header('新增品牌')" />
	<th:block th:include="include :: jasny-bootstrap-css" />
	<script th:src="@{/js/jquery.min.js}"></script>
<!--	<th:block th:include="include :: summernote-css" />-->
	<th:block th:include="include :: jasny-bootstrap-js" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="goods-brand-add">
			<div class="form-group">	
				<label class="col-sm-2 control-label is-required">品牌名称：</label>
				<div class="col-sm-10">
					<input id="brandName" name="brandName" class="form-control" type="text" required>
				</div>
			</div>

			<div class="form-group form-group1">
				<label class="col-sm-2 control-label is-required">品牌图片：</label>
				<div class="col-sm-10 fileinput fileinput-new" data-provides="fileinput">
					<div class="fileinput-preview thumbnail"  data-trigger="fileinput" style="width: 200px; height: 150px;"></div>
					<input type="hidden" name="brandImage" id="brandImage">
					<div>
						<span class="btn btn-white btn-file"><span class="fileinput-new">选择图片</span>
							<span class="fileinput-exists">更改</span><input type="file" name="uploadImage"  id="uploadImage"></span>
						<a href="#" class="btn btn-white fileinput-exists" data-dismiss="fileinput">清除</a>
					</div>
				</div>
			</div>


			<div class="form-group">
				<label class="col-sm-2 control-label">状态：</label>
				<div class="col-sm-10">
					<select id="post" class="form-control m-b" name="isShow">
						<option value="1" selected>显示</option>
						<option value="0">隐藏</option>
					</select>
				</div>
			</div>


			<div class="form-group">
				<label class="col-sm-2 control-label is-required">显示排序：</label>
				<div class="col-sm-10">
					<input class="form-control" type="text" name="orderNum" required>
				</div>
			</div>



		</form>
	</div>
    <th:block th:include="include :: footer" />
<!--    <th:block th:include="include :: summernote-js" />-->
    <script type="text/javascript">
        var prefix = ctx + "goods/brand";

		$('#uploadImage').on('change.bs.fileinput ', function (e) {
			// 处理自己的业务
			var file = this.files[0];
			sendFile(file,"brandImage");
		});

		// 上传文件
		function sendFile(file,elemId) {
			var data = new FormData();
			data.append("file", file);
			$.ajax({
				type: "POST",
				url: ctx + "common/upload",
				data: data,
				cache: false,
				contentType: false,
				processData: false,
				dataType: 'json',
				success: function(result) {
					if (result.code == web_status.SUCCESS) {
						$('#'+elemId).val(result.fileName);
					} else {
						$.modal.alertError(result.msg);
					}
				},
				error: function(error) {
					$.modal.alertWarning("图片上传失败。");
				}
			});
		}
		
		$("#goods-brand-add").validate({
			focusCleanup: true
		});
		
		function submitHandler() {
	        if ($.validate.form()) {
	        	// var sHTML = $('.summernote').summernote('code');
				// $("#noticeContent").val(sHTML);
				$.operate.save(prefix + "/add", $('#goods-brand-add').serialize());
	        }
	    }
	</script>
</body>
</html>
